package com.sl.au.repository;

import java.util.Map;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.sl.au.entity.ContractBillInfo;


@Transactional
public interface PaymentSearchForViewRespository extends JpaRepository<ContractBillInfo, String>{
	
	@Query(" select s from ContractBillInfo s where s.cSuperior = ?1 and s.dNotionalPoolingYearAndMonth = ?2 and s.state = '正常' "
			+ " and ( s.cSupplierCode like '%'+?3+'%' or s.cOrderUnit like '%'+?3+'%'"
			+ " or s.cProjectName like '%'+?3+'%' or s.cDemanderCode like '%'+?3+'%'"
			+ " or s.cProductKind like '%'+?3+'%' or s.cCheckKind like '%'+?3+'%'"
			+ " or s.cDutyOfficer like '%'+?3+'%' or s.cOrderArea like '%'+?3+'%'"
			+ " or s.cPayType like '%'+?3+'%')")
	//@Query(" select s from ContractBillInfo s where ?1 ")
    Page<ContractBillInfo> getContractBillInfo(String superiorTop,String monthYear,String key,Pageable pageable);
	
	@Query(" select s from ContractBillInfo s where s.cSuperior = ?1 and s.dNotionalPoolingYearAndMonth = ?2 and s.state = '正常'")
	Page<ContractBillInfo> getContractBillInfo(String superiorTop,String monthYear,Pageable pageable);
	//Page<ContractBillInfo> getContractBillInfo(String whereStr,Pageable pageable);

	@Query(" select count(s) from ContractBillInfo s where s.cSuperior = ?1 and s.dNotionalPoolingYearAndMonth = ?2 "
			+ " and ( s.cSupplierCode like '%'+?3+'%' or s.cOrderUnit like '%'+?3+'%'"
			+ " or s.cProjectName like '%'+?3+'%' or s.cDemanderCode like '%'+?3+'%'"
			+ " or s.cProductKind like '%'+?3+'%' or s.cCheckKind like '%'+?3+'%'"
			+ " or s.cDutyOfficer like '%'+?3+'%' or s.cOrderArea like '%'+?3+'%'"
			+ " or s.cPayType like '%'+?3+'%')")
	//@Query(" select count(s) from ContractBillInfo s where ?1 ")
    long getCount(String superiorTop,String monthYear,String key);
	//long getCount(String whereStr);
	
	@Query(" select count(s) from ContractBillInfo s where s.cSuperior = ?1 and s.dNotionalPoolingYearAndMonth = ?2 ")
	long getCount(String superiorTop,String monthYear);
}
